
/**
 * Module dependencies.
 */

var express = require('express')
  , routes = require('./routes')
  , http = require('http')
  , path = require('path')
  , passport = require('passport');

var app = express();

// all environments

app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger());
app.use(express.cookieParser());

app.use(express.bodyParser({
	keepExtensions:true,
	uploadDir:__dirname+"/tmp/files",
	limit:"10mb"	
}));

app.use(express.methodOverride());
app.use(express.session({ secret: 'keyboard cat' }));
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));

// development only
if ('development' == app.get('env')) {
  app.use(express.errorHandler());
}

app.get('/', routes.index);
app.get('/empresa', routes.companyMenu);
app.get('/categorias', routes.categories);

var movilRest = require('./restful/webRest')(app);
//cargamos el modulo de autentificación con facebook t twitter
require('./src/clases/authentification')(app,passport);

//cargamos modulo para subir archivos
require("./src/clases/uploadFile")(app,path);


//.- test

app.get("/user-setting",function(req,res){
	res.render('./setting/user',{user:req.user});
});
app.get("/company-setting",function(req,res){
	res.render('./setting/company',{user:req.user});
});



http.createServer(app).listen(app.get('port'), function(){
  console.log('Express server listening on port ' + app.get('port'));
});
